define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'member/lists/index' + location.search,
                    // add_url: 'member/lists/add',
                    // edit_url: 'member/lists/edit',
                    // del_url: 'member/lists/del',
                    multi_url: 'member/lists/multi',
                    table: 'users',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'uuid', title: __('Uuid')},
                        {field: 'invite_code', title: __('Invite_code')},
                        {field: 'pid', title: __('Pid')},
                        {field: 'phone', title: __('Phone')},
                        {field: 'mailbox', title: __('Mailbox')},
                        {field: 'headimg', title: __('Headimg'), formatter: Table.api.formatter.image},
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        {field: 'level', title: __('Level'), searchList: {"0":__('Level 0'),"1":__('Level 1'),"2":__('Level 2'),"3":__('Level 3')}, formatter: Table.api.formatter.normal},
                        {field: 'nickname', title: __('Nickname')},
                        {field: 'truename', title: __('Truename')},
                        {field: 'usdt_address', title: __('Usdt_address')},
                        {field: 'id_card', title: __('Id_card')},
                        {field: 'is_customs', title: __('Is_customs'), searchList: {"0":__('Is_customs 0'),"1":__('Is_customs 1')}, formatter: Table.api.formatter.normal},
                        {field: 'is_attestation', title: __('Is_attestation'), searchList: {"0":__('Is_attestation 0'),"1":__('Is_attestation 1'),"2":__('Is_attestation 2')}, formatter: Table.api.formatter.normal},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange'},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});